package cn.com.dhc.zzz.back.action;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.bbs.ba.base.BAAction;
import cn.bbs.ba.dao.BAADaoOperate;
import cn.bbs.ba.db.Fetcher;
import cn.bbs.ba.error.DTOViewMsg;
import cn.bbs.ba.factory.BABeanFactory;
import cn.bbs.ba.session.SessionDto;
import cn.bbs.ba.session.SessionFactory;
import cn.bbs.ba.util.CommonUntil;
import cn.com.zzz.dao.PkAccInfoDao;
import cn.com.zzz.pk.dto.PkAccInfo;
import cn.com.zzz.pk.dto.PkRoom;

/**
 * 后台菜单指定页面
 */
public class MenuAction extends BAAction {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		super.execute(mapping, form, request, response);
		DTOViewMsg msg = new DTOViewMsg();
		request.setAttribute("MSG", msg);
		String strPage = CommonUntil.objToString(request.getParameter("yemian"));
		if (StringUtils.isEmpty(strPage)) {
			return mapping.findForward("houtaidenglu");
		}

		SessionDto sessionDto = SessionFactory.getSessionDto(request);
		if (sessionDto == null) {
			return mapping.findForward("comError");
		}
		// 权限
		int lever = CommonUntil.objToint(sessionDto.getKbn());
		
		// 添加用户
		if (lever > 1 && "addUser".equals(strPage)) {
			return mapping.findForward("addUserPage");
		}
		// 查看个人资料
		else if("CKGRZL".equals(strPage)) {
			return mapping.findForward("chakangerenziliao");
		}
		// 修改个人资料
		else if("XGGRZL".equals(strPage)) {
			return mapping.findForward("xiugaigerenziliao");
		}
		// 更改登录密码
		else if("XGDLMM".equals(strPage)) {
			return mapping.findForward("xiugaigerenmima");
		}
		// 充值
		else if("accNochongzhi".equals(strPage)) {
			return mapping.findForward("chongzhi");
		}
		// 追加账号
		else if("accNoAdd".equals(strPage)) {
			return mapping.findForward("zhuijiazhanghao");
		}
		// 管理账户明细
		else if("accNoEdit".equals(strPage)) {
			PkAccInfoDao accInfoDao = (PkAccInfoDao)BABeanFactory.getBean("ACCINFO");
			PkAccInfo accInfo = new PkAccInfo();
			
			accInfo.setUserNo(super.userInfo.getUserNo());
			request.setAttribute("accList", accInfoDao.getAccInfo(accInfo, "0"));
			return mapping.findForward("guanlizhanghao");
		}
		// 取款
		else if("accNoGateMoney".equals(strPage)) {
			PkAccInfoDao accInfoDao = (PkAccInfoDao)BABeanFactory.getBean("ACCINFO");
			PkAccInfo accInfo = new PkAccInfo();
			
			accInfo.setUserNo(super.userInfo.getUserNo());
			request.setAttribute("accList", accInfoDao.getAccInfo(accInfo, "0"));
			return mapping.findForward("qukuan");
		}
		// 查看金钱流水
		else if("accNoCheckGateMoneyLiushui".equals(strPage)) {
			return mapping.findForward("accNoCheckGateMoneyLiushui");
		}
		// 充值
		else if("accNochongzhi".equals(strPage)) {
			return mapping.findForward("chongzhi");
		}
		// 房间管理
		else if("editRoom".equals(strPage)) {
			HashMap<String, String> strMap = new HashMap<String, String>();
			strMap.put(BAADaoOperate.SQL_ID, "searchRoomInfo");
			Fetcher<PkRoom> dtoFetch = BAADaoOperate.search(strMap, PkRoom.class);
			request.setAttribute("roomList", dtoFetch);
			return mapping.findForward("editRoom");
		}
		// 押注等待时间
		else if("edityzddsj".equals(strPage)) {
			return mapping.findForward("edityzddsj");
		}
		// 桌子开始扣除钱数
		else if("editStartKcqs".equals(strPage)) {
			return mapping.findForward("editStartKcqs");
		}
		return mapping.findForward("comError");
	}

}
